<h1>Listing <%= 'Default ' if (! @project) %>Templates</h1>

<p>
<b>Filter by</b>: 
<%= link_to_if @filter[:type] != 'All', 'All', 'filter[type]' => 'All' %> |
<%= link_to_if @filter[:type] != 'Templet', 'Bulletins', 'filter[type]' => 'Templet' %> |
<%= link_to_if @filter[:type] != 'Email', 'Emails', 'filter[type]' => 'Email' %> |
<%= link_to_if @filter[:type] != 'Page', 'Pages', 'filter[type]' => 'Page' %>
<% if ENABLE_CONTENT_PAGES %>
  | <%= link_to_if @filter[:type] != 'ContentTemplet', 'Content Pages', 'filter[type]' => 'ContentTemplet' %>
<% end %> 
  
</p>

<table>
  <tr>
  	<th>Name</th>
  	<th>Type</th>
  	<th>Updated</th>
  </tr>
  
<% for templet in @templets %>
  <tr>
  	<td><b><%= link_to_if (! @project or templet.project_id != 0), templet.send('name'), :controller => 'templet_layouts', :action => 'list', :templet_id => templet %></b>
  	  <%= (templet.project_id == 0) ? ' - default' : '' %>
  	</td>  
  	<td><%=h templet.type_name %></td>
  	<td><%=h templet.updated_on %></td>
  	<td><%= link_to 'Layouts', :controller => 'templet_layouts', :action => 'list', :templet_id => templet if (! @project or templet.project_id != 0) %> </td>
    <td><%= link_to ((@project and templet.project_id == 0) ? image_tag("add.png", :title => "copy", :border=>"0") : image_tag("edit.png", :title=>"edit", :border=>"0")),
         :action => 'edit', :id => templet %></td>
    <td><%= link_to(image_tag("destroy.png", :title=>"destroy", :border=>"0"), { :action => 'destroy', :id => templet }, :confirm => 'Are you sure?', :method => :post) if (! (@project and templet.project_id == 0)) %></td>
    <td><%= link_to(image_tag("send.png", :border => 0, :title=> "Send Test"), {:action => 'send_test', :id => templet }) if (templet.is_a? Email) %></td>
  </tr>
<% end %>
</table>

<p>
<%= link_to 'Previous page', { :page => @templet_pages.current.previous, 'filter[type]' => @filter[:type] } if @templet_pages.current.previous %>
<%= link_to 'Next page', { :page => @templet_pages.current.next, 'filter[type]' => @filter[:type] } if @templet_pages.current.next %> 
</p>

<br />

<%= link_to image_tag("add.png", :border=>"0")+' New template', :action => 'new' %> | 
<% if @project %>
  <%= link_to 'Bulletins', :controller => 'bulletins', :action => 'list' %>
<% else %>
  <%= link_to 'Projects', :controller => 'projects', :action => 'list' %>
<% end %>
